
#include "Services.h"
#include "ServiceBase.h"

using namespace ttg::services;

//----------------
//--- Services ---
//----------------

Services::Services(bool should_start)
{
	if (should_start)
		start();
}

void Services::start()
{
	std::string configuration;
	configuration.append(logger_settings.serialize());
	configuration.append("&SettingsKeeper");
	configuration.append("&DllLoader");
	configuration.append("&DeviceAnalyzer");
	configuration.append("&CPUAnalyzer");
	configuration.append("&PublisherBase");
	configuration.append(std::string("&") + task_scheduler_settings.serialize());
	configuration.append("&Timer");
	configuration.append("&UtilManager");
	ServiceBase::getRef()->start(configuration.c_str());
}

void Services::stop()
{
	ServiceBase::getRef()->stop();
}

Services::~Services()
{
	try
	{ stop(); }
	catch (ttg::Error &) { }
}
